package com.macaline.service.impl.user;

import com.macaline.Golbal;
import com.macaline.mapper.UserMapper;
import com.macaline.entity.User;
import com.macaline.service.user.AdminUserService;
import com.macaline.util.DateUtil;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminUserServiceImpl implements AdminUserService {

    @Resource
    UserMapper userMapper;


    @Override
    public User addUser(User user) {
        Integer time = DateUtil.getTime4Linux10();
        user.setRegTime(time);
        user.setRoleId(User.ADMIN_ROLE_ID);
        user.setSalt("1234");
        String md5Password = new Md5Hash(String.valueOf(user.getPassWord()).toString(), user.getSalt(), Golbal.USER_PASSWORD_MD5_HASHITERATIONS).toString();
        userMapper.insert(user);
        return user;
    }

}
